Skip to content

removed std::forward(args) from operator() methods#6

Open
tyhenry wants to merge 1 commit intocpp11nullptr:masterfrom
tyhenry:master
Open

removed std::forward(args) from operator() methods#6
tyhenry wants to merge 1 commit intocpp11nullptr:masterfrom
tyhenry:master

Conversation

@tyhenry
Copy link

@tyhenry tyhenry commented Apr 16, 2020

this fixes a bug where signal argument types with move c'tors (i.e. std::string, std::vector, etc.) would be invalidated by the first callback.

e.g.

signal<void(std::string)> signalStr;

int i = 0;
auto fn = [&i](std::string s) { std::cout << ++i << ": " << s << std::endl; };
signalStr.connect( fn );
signalStr.connect( fn );

std::string str = "hello";
signalStr( str );

/*

before fix:

1: hello
2: 

after fix:

1: hello
2: hello

*/

… prevent move c'tor invalidation, e.g. signal(std::string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant